package com.ruoyi.web.controller.douyin;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.DyAnchor;
import com.ruoyi.system.domain.DyAnchorPhoto;
import com.ruoyi.system.domain.bo.DyAnchorBo;
import com.ruoyi.system.domain.bo.DyAnchorPhotoBo;
import com.ruoyi.system.domain.bo.DyCustomerSumBo;
import com.ruoyi.system.domain.vo.DyAnchorCustomerVo;
import com.ruoyi.system.domain.vo.DyAnchorVo;
import com.ruoyi.system.service.IDyAnchorPhotoService;
import com.ruoyi.system.service.IDyAnchorService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 主播相册
 *
 * @author ruoyi
 * @date 2024-06-20
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/anchor/photo")
public class DyAnchorPhotoController extends BaseController {

    private final IDyAnchorPhotoService iDyAnchorPhotoService;

    /**
     * 查询主播图片列表
     */
    @GetMapping("/list")
    public TableDataInfo<DyAnchorPhoto> list(DyAnchorPhotoBo bo, PageQuery pageQuery) {
        return iDyAnchorPhotoService.queryPageList(bo, pageQuery);
    }

    /**
     * 获取主播照片详细信息
     *
     * @param bo 主键
     */
    @PostMapping("/getAnchorPhotoById")
    public R<DyAnchorPhotoBo> getAnchorPhotoById(@RequestBody DyAnchorPhotoBo bo) {
        DyAnchorPhotoBo photo = iDyAnchorPhotoService.getAnchorPhotoById(bo);
        return R.ok(photo);
    }


    /**
     * 新增主播照片
     */
    @Log(title = "主播照片", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/addAnchorPhoto")
    public R<Void> addAnchorPhoto(@Validated(AddGroup.class) @RequestBody DyAnchorPhotoBo bo) {
        return toAjax(iDyAnchorPhotoService.insertByBo(bo));
    }

    /**
     * 修改主播照片
     */
    @Log(title = "主播照片", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/editAnchorPhoto")
    public R<Void> editAnchorPhoto(@Validated(EditGroup.class) @RequestBody DyAnchorPhotoBo bo) {
        return toAjax(iDyAnchorPhotoService.updateByBo(bo));
    }

    /**
     * 删除主播照片
     *
     * @param
     */
    @Log(title = "主播照片", businessType = BusinessType.DELETE)
    @PostMapping("/delAnchorPhoto")
    public R<Void> delAnchorPhoto(@RequestBody DyAnchorPhotoBo bo) {
        return toAjax(iDyAnchorPhotoService.delAnchorPhoto(bo));
    }

//    /**
//     * 导出主播列表
//     */
//    @SaCheckPermission("system:anchor:export")
//    @Log(title = "主播", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(DyAnchorBo bo, HttpServletResponse response) {
//        List<DyAnchorVo> list = iDyAnchorService.queryList(bo);
//        ExcelUtil.exportExcel(list, "主播", DyAnchorVo.class, response);
//    }
}
